<template>
  <custom-modal
    ref="createModal"
    v-if="visible"
    :width="width"
    :visible="visible"
    :title="title"
    :destroyOnClose="true"
    :attrs="{ dialogClass: 'partUpdateExceptionLogDialog' }"
    :bodyStyle="{ height }"
    @cancel="handleCancel"
    @full="resize"
  >
    <template #footer>
      <a-button type="primary" @click="downloadAllFile" :loading="downloading" v-if="compt=='showCarLog'">
        全部日志下载
      </a-button>
      <a-button
        type="primary"
        @click.stop="()=>{visible=false}"
      >{{ $t('back') }}</a-button>
    </template>
    <div class="partUpdateExceptionLogContWrap" :style="{height:'100%'}">
      <part-update-exception-index ref="PartUpdateExceptionRef" @downloadType="downloadType" :defaultQuery="query" :compt="compt"></part-update-exception-index>
    </div>
  </custom-modal>
</template>
<script>
import PartUpdateExceptionIndex from './index.vue'
import CustomModal from '@/components/CustomModal/index.vue'
import { downloadBlobFile } from '@/utils/functions'
export default {
  components: {
    PartUpdateExceptionIndex,
    CustomModal
  },
  props: {
    // 适配其他组件
    compt:{
      type: String,
      default: ''
    },
    // 打包文件信息
    packageFile:{
      type: Object,
      default () {
        return null
      }
    },
    title:{
      type: String,
      default: '异常日志'
    },
    width: {
      type: String,
      default: '50%'
    },
    height: {
      type: String,
      default: 'auto'
    },
    // 查询条件
    query: {
      type: Object,
      default () {
        return null
      }
    }
  },
  data () {
    return {
      visible: false,
      submitDisabled: true,
      downloading: false
    }
  },
  methods: {
    resize(){
      this.$refs.PartUpdateExceptionRef.resize()
    },
    downloadType(val){
      this.downloading=val
    },
    downloadAllFile () {
      this.$refs.PartUpdateExceptionRef.downloadAllFile(this.packageFile)
    },
    handleCancel () {
      this.visible = false
    },
    switchVisible (val) {
      this.visible = val
    },
  }
}
</script>
<style lang="less" scoped>
.partUpdateExceptionLogDialog {
    .partUpdateExceptionLogContWrap {
        overflow-y: auto;
        overflow-x: hidden;
        padding-top:20px;
    }
}
</style>
<style lang="less">
.partUpdateExceptionLogDialog {
    .ant-modal-footer {
        padding:12px 24px;
    }
}
</style>
